package com.ruoyi.project.module.feeset.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.module.feeset.domain.Feeset;
import com.ruoyi.project.module.feeset.service.IFeesetService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 会员套餐管理Controller
 * 
 * @author javen
 * @date 2020-12-26
 */
@Controller
@RequestMapping("/module/feeset")
public class FeesetController extends BaseController
{
    private String prefix = "module/feeset";

    @Autowired
    private IFeesetService feesetService;

    @RequiresPermissions("module:feeset:view")
    @GetMapping()
    public String feeset()
    {
        return prefix + "/feeset";
    }

    /**
     * 查询会员套餐管理列表
     */
    @RequiresPermissions("module:feeset:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Feeset feeset)
    {
        startPage();
        List<Feeset> list = feesetService.selectFeesetList(feeset);
        return getDataTable(list);
    }

    /**
     * 导出会员套餐管理列表
     */
    @RequiresPermissions("module:feeset:export")
    @Log(title = "会员套餐管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Feeset feeset)
    {
        List<Feeset> list = feesetService.selectFeesetList(feeset);
        ExcelUtil<Feeset> util = new ExcelUtil<Feeset>(Feeset.class);
        return util.exportExcel(list, "feeset");
    }

    /**
     * 新增会员套餐管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存会员套餐管理
     */
    @RequiresPermissions("module:feeset:add")
    @Log(title = "会员套餐管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Feeset feeset)
    {
        return toAjax(feesetService.insertFeeset(feeset));
    }

    /**
     * 修改会员套餐管理
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        Feeset feeset = feesetService.selectFeesetById(id);
        mmap.put("feeset", feeset);
        return prefix + "/edit";
    }

    /**
     * 修改保存会员套餐管理
     */
    @RequiresPermissions("module:feeset:edit")
    @Log(title = "会员套餐管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Feeset feeset)
    {
        return toAjax(feesetService.updateFeeset(feeset));
    }

    /**
     * 删除会员套餐管理
     */
    @RequiresPermissions("module:feeset:remove")
    @Log(title = "会员套餐管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(feesetService.deleteFeesetByIds(ids));
    }
}
